home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_11_03 / 1103111a < prev    next >
Text File  |  1993-01-06  |  849b  |  43 lines

  1. // tv1.cpp - a test program for float_vectors and
  2. // float_arrays
  3.  
  4. #include <iostream.h>
  5. #include "fv1.h"
  6.  
  7. void display(const char *s, const float_array &fa)
  8.     {
  9.     cout << s << " = " << fa << endl;
  10.     }
  11.  
  12. int main()
  13.     {
  14.     int i, low, high;
  15.     cout << "low? ";
  16.     cin >> low;
  17.     cout << "high? ";
  18.     cin >> high;
  19.  
  20.     float_vector fa(low, high);
  21.     for (i = fa.low(); i <= fa.high(); ++i)
  22.         fa[i] = i;
  23.     display("fa", fa);
  24.     float_vector fb = fa;
  25.     display("fb", fb);
  26.     for (i = low; i < low + 2 * fa.length(); ++i)
  27.         {
  28.         fb[i] = i * i;
  29.         display("fb", fb);
  30.         }
  31.     cout << "fb.low() = " << fb.low() << '\n';
  32.     cout << "fb.high() = " << fb.high() << '\n';
  33.     float_array fc = fa;
  34.     display("fc", fc);
  35.     i = fc.length();
  36.     fc[i - 1] = 123;
  37.     display("fc", fc);
  38.     cout << "fa[" << low - 1 << "] = ";
  39.     cout << fa[low - 1] << '\n';
  40.     return 0;
  41.     }
  42.  
  43.